﻿using Hidistro.Core;
using Hidistro.UI.Common.Controls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class wnxd_SpreadPage_Info : AscxTemplatedWebControl
    {
        Repeater r1, r2;
        protected override void AttachChildControls()
        {
            this.r1 = (Repeater)this.FindControl("r1");
            this.r2 = (Repeater)this.FindControl("r2");
            DataTable dt = this.sql_call("select * from Hishop_Orders where OrderDate > '" + DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd") + "' and OrderStatus != 4 and OrderId in (select OrderId from Hishop_OrderItems where SkuId like '%_898' or SkuId like '%_899' or SkuId like '%_900' group by OrderId)");
            this.r1.DataSource = dt;
            this.r2.DataSource = dt;
            this.r1.DataBind();
            this.r2.DataBind();
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/ascx/tags/wnxd_SpreadPage_Info.ascx";
            }
            base.OnInit(e);
        }
        Database database = DatabaseFactory.CreateDatabase();
        private DataTable sql_call(string sql)
        {
            using (DbCommand cmd = database.GetSqlStringCommand(sql))
            using (IDataReader reader = database.ExecuteReader(cmd))
            {
                return DataHelper.ConverDataReaderToDataTable(reader);
            }
        }
    }
}
